package com.kayak.service.butterfly.demo;

import java.io.InputStream;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.kayak.dbutil.sql.SqlException;
import com.kayak.dbutil.sql.SqlResult;
import com.kayak.dubbo.bean.RpcBean;
import com.kayak.exception.ErrorException;
import com.kayak.kkutils.strutil.StringUtil;
import com.kayak.service.butterfly.demo.ButterflyDemoInterface;
import com.kayak.service.resource.transbase.RpcBase;
import com.kayak.service.resource.util.ErrorCodeButterfly;

public class ButterflyDemoServiceImpl extends RpcBase implements ButterflyDemoInterface {
	public final static Logger log = LoggerFactory.getLogger(ButterflyDemoServiceImpl.class);

	@Override
	public void init(RpcBean rpcBean) throws ErrorException {
		
		
	}

	@Override
	public void check(RpcBean rpcBean) throws ErrorException {
		StringUtil.checkNeedDatas("resource_id", rpcBean.getLocalMap());
	}

	@Override
	public void doBusiness(RpcBean rpcBean) throws ErrorException {
		SqlResult result = this.comnDao.query("kbutterfly_demo_sql", rpcBean.getLocalMap());
		Map<String, Object> avatarUrl=null;
		try {
			avatarUrl = result.getRow(0);
			rpcBean.addResponse("avatarUrl",avatarUrl );
		} catch (SqlException e) {
			throw new ErrorException(ErrorCodeButterfly.ERROR_RESOURCE_100001_CODE,
					ErrorCodeButterfly.ERROR_RESOURCE_100001_MSG);
		}
		
	}

	@Override
	public void doBusiness(RpcBean rpcBean, InputStream in)
			throws ErrorException {
		
		
	}




}
